<?php
    header('Access-Control-Allow-Origin: *');
    header('Content-Type:application/json;charset=utf-8');
    $con = mysqli_connect("127.0.0.1", "root", "root", "mydb");
    $uId = $_GET['uid'];
    $status = $_GET['status'];
    if($status == 'student'){
        $sql = "SELECT l.l_id,l.l_name,t.t_name,l.l_time,l.l_place,l.isSign FROM stu_info as s INNER JOIN lessonStu as ls on s.stu_id = ls.s_id INNER JOIN lesson as l on l.l_id = ls.l_id INNER JOIN tch_info as t on t.t_id = l.teacher_id WHERE s.stu_id = '$uId' AND ls.state = 'success';";
    }else if($status == 'teacher'){
        $sql = "SELECT l.l_id,l.l_name,t.t_name,l.l_time,l.l_place,l.isSign FROM lesson AS l INNER JOIN tch_info AS t ON l.teacher_id = t.t_id WHERE t.t_id = '$uId';";
    }
    $res = mysqli_query($con,$sql);
    $list = array();
    $total = 0;
    while($row = mysqli_fetch_array($res)){
        $item = array(
            'l_id' => $row['l_id'],
            'l_name' => $row['l_name'],
            't_name' => $row['t_name'],
            'l_time' => $row['l_time'],
            'l_place' => $row['l_place'],
            'isSign' => $row['isSign']
        );
        array_push($list,$item);
    }
    echo json_encode(array(
        'list'=>$list,
    ));
    mysqli_close($con);
?>